{extend name='public/window' /}

{block name="content"}
<style type="text/css">
    .laydate_table {
        display: none;
    }

    #laydate_hms {
        display: none !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
                <div class="tianxie">
                    <input type="hidden" name="__token__" id="token" value="{:token()}"/>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">月份</label>
                            <div class="layui-input-inline">
                                <input type="text" id="start_time" name="start_time" class="layui-input"
                                       placeholder="选择月份">
                            </div>
                        </div>
                    </div>
                    <div class="feilv">
                        <div class="layui-form-item">
                            <label class="layui-form-label">峰电价 *</label>
                            <div class="layui-input-block">
                                <input type="digit" name="fmoney"
                                       placeholder="请输入单价" class="layui-input" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">谷电价 *</label>
                            <div class="layui-input-block">
                                <input type="digit" name="gmoney"
                                       placeholder="请输入单价" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">平电价 *</label>
                            <div class="layui-input-block">
                                <input type="digit" name="pmoney"
                                       placeholder="请输入单价" class="layui-input" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">写字楼分摊电价 *</label>
                            <div class="layui-input-block">
                                <input type="digit" name="tmoney"
                                       placeholder="请输入单价" class="layui-input" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商场分摊电价 *</label>
                            <div class="layui-input-block">
                                <input type="digit" name="stmoney"
                                       placeholder="请输入单价" class="layui-input" >
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item danyi">
                        <label class="layui-form-label">零售单价 *</label>
                        <div class="layui-input-block">
                            <input type="digit" name="linmoney"  placeholder="请输入单价"
                                   value="" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">总电量 *</label>
                        <div class="layui-input-block">
                            <input type="digit" name="alluse"  placeholder="请输入总电量"
                                   value="" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="chuang" style="text-align: center">
                    <button class="layui-btn"  lay-submit="" lay-filter="add">确认创建</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/html" id="operationTpl">
    <a href="javascript:;" class="layui-btn  layui-btn-danger layui-btn-xs" data-title="删除" lay-event="del"><i
            class="layui-icon "></i></a>
</script>
<script>
    layui.use(['element', 'form', 'table', 'jquery', 'lucky', 'laydate', 'xmSelect'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var lucky = layui.lucky;
        var id_lists = [];
        laydate.render({
            elem: '#start_time',
            type: 'month',
            format: 'yyyy-MM',
            trigger: 'click',
            value: doHandleDate(),
            max: doHandleDate(), //最大月
        });
        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('add')}", data.field, true);
            return false;
        });
        table.on('tool(table_id)', function (obj) {
            var data = obj.data;
            var _id=parseInt(data.id);
            var layEvent = obj.event;
           if(layEvent==="del"){
                lucky.FormatData(_id,"{:url('del')}");
                return false;
            }
        });
        table.on('toolbar(table_id)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if(obj.event==="del"){
                var num=0;
                var id=[];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num<1) {
                    layer.msg("请选择一项",{time:1500});return false;
                }
                lucky.FormatData(id,"{:url('del')}");
                return  false;
            }
        });
        ///获取年月
        function doHandleDate() {
            var myDate = new Date();
            var tYear = myDate.getFullYear();
            var tMonth = myDate.getMonth();

            var m = tMonth;
            if (m.toString().length == 1) {
                m = "0" + m;
            }
            return tYear + '-' + m;
        }
    })

</script>

{/block}

